package com.xintai.system.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.xintai.common.annotation.Log;
import com.xintai.common.core.controller.BaseController;
import com.xintai.common.core.domain.AjaxResult;
import com.xintai.common.enums.BusinessType;
import com.xintai.system.domain.ErpWorkshopcangku;
import com.xintai.system.service.IErpWorkshopcangkuService;
import com.xintai.common.utils.poi.ExcelUtil;
import com.xintai.common.core.page.TableDataInfo;

/**
 * 生产线关联仓库Controller
 * 
 * @author xintai
 * @date 2021-01-08
 */
@RestController
@RequestMapping("/system/workshopcangku")
public class ErpWorkshopcangkuController extends BaseController
{
    @Autowired
    private IErpWorkshopcangkuService erpWorkshopcangkuService;

    /**
     * 查询生产线关联仓库列表
     */
    @PreAuthorize("@ss.hasPermi('system:workshopcangku:list')")
    @GetMapping("/list")
    public TableDataInfo list(ErpWorkshopcangku erpWorkshopcangku)
    {
        startPage();
        List<ErpWorkshopcangku> list = erpWorkshopcangkuService.selectErpWorkshopcangkuList(erpWorkshopcangku);
        return getDataTable(list);
    }

    /**
     * 导出生产线关联仓库列表
     */
    @PreAuthorize("@ss.hasPermi('system:workshopcangku:export')")
    @Log(title = "生产线关联仓库", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(ErpWorkshopcangku erpWorkshopcangku)
    {
        List<ErpWorkshopcangku> list = erpWorkshopcangkuService.selectErpWorkshopcangkuList(erpWorkshopcangku);
        ExcelUtil<ErpWorkshopcangku> util = new ExcelUtil<ErpWorkshopcangku>(ErpWorkshopcangku.class);
        return util.exportExcel(list, "workshopcangku");
    }

    /**
     * 获取生产线关联仓库详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:workshopcangku:query')")
    @GetMapping(value = "/{wcId}")
    public AjaxResult getInfo(@PathVariable("wcId") Integer wcId)
    {
        return AjaxResult.success(erpWorkshopcangkuService.selectErpWorkshopcangkuById(wcId));
    }

    /**
     * 新增生产线关联仓库
     */
    @PreAuthorize("@ss.hasPermi('system:workshopcangku:add')")
    @Log(title = "生产线关联仓库", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ErpWorkshopcangku erpWorkshopcangku)
    {
        return toAjax(erpWorkshopcangkuService.insertErpWorkshopcangku(erpWorkshopcangku));
    }

    /**
     * 修改生产线关联仓库
     */
    @PreAuthorize("@ss.hasPermi('system:workshopcangku:edit')")
    @Log(title = "生产线关联仓库", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ErpWorkshopcangku erpWorkshopcangku)
    {
        return toAjax(erpWorkshopcangkuService.updateErpWorkshopcangku(erpWorkshopcangku));
    }

    /**
     * 删除生产线关联仓库
     */
    @PreAuthorize("@ss.hasPermi('system:workshopcangku:remove')")
    @Log(title = "生产线关联仓库", businessType = BusinessType.DELETE)
	@DeleteMapping("/{wcIds}")
    public AjaxResult remove(@PathVariable Integer[] wcIds)
    {
        return toAjax(erpWorkshopcangkuService.deleteErpWorkshopcangkuByIds(wcIds));
    }
}
